#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 8000
#define M 32000
using namespace std;
const int inf=(int)(1e9);
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
struct matrix
{
	int l1,r1,l2,r2;
	bool operator < (const matrix &t)const
	{
		return 1ll*(r1-l1+1)*(r2-l2+1)>1ll*(t.r1-t.l1+1)*(t.r2-t.l2+1);
	}
};
matrix tong[M+1];
int n,length,h[N+1],dp[N+1],dp2[N+1],dp3[N+1],dp4[N+1],DP[N+1],DP2[N+1],DP3[N+1],DP4[N+1];
bool used[M+1];
void append(int x,int l1,int r1,int l2,int r2)
{
	DP[x]=max(DP[x],min(x-l1,h[x]-l2));
	DP2[x]=max(DP2[x],min(x-l1,r2-h[x]));
	DP3[x]=max(DP3[x],min(r1-x,h[x]-l2));
	DP4[x]=max(DP4[x],min(r1-x,r2-h[x]));
	return;
}
int main()
{
	freopen("build.in","r",stdin);
	freopen("build.out","w",stdout);
	bool op;
	n=read();
	for (int i=1;i<=n;++i) h[i]=read(),dp[i]=min(i-1,h[i]-1),dp2[i]=min(i-1,n-h[i]),dp3[i]=min(n-i,h[i]-1),dp4[i]=min(n-i,n-h[i]);
	for (int i=2;;++i)
	{
		for (int j=1;j<=n;++j) DP[j]=DP2[j]=DP3[j]=DP4[j]=-inf;
		length=0;
		for (int j=1;j<=n;++j)
		{
			if (dp[j]>0) tong[++length]=(matrix){j-dp[j],j-1,h[j]-dp[j],h[j]-1};
			if (dp2[j]>0) tong[++length]=(matrix){j-dp2[j],j-1,h[j]+1,h[j]+dp2[j]};
			if (dp3[j]>0) tong[++length]=(matrix){j+1,j+dp3[j],h[j]-dp3[j],h[j]-1};
			if (dp4[j]>0) tong[++length]=(matrix){j+1,j+dp4[j],h[j]+1,h[j]+dp4[j]};
		}
		sort(tong+1,tong+length+1);
		for (int j=1;j<=min(length,500);++j)
		{
			for (int k=tong[j].l1;k<=tong[j].r1;++k)
				if (tong[j].l2<=h[k]&&h[k]<=tong[j].r2)
					append(k,tong[j].l1,tong[j].r1,tong[j].l2,tong[j].r2);
		}
		op=0;
		for (int j=1;j<=n;++j) dp[j]=DP[j],dp2[j]=DP2[j],dp3[j]=DP3[j],dp4[j]=DP4[j],op|=(dp[j]!=-inf||dp2[j]!=-inf||dp3[j]!=-inf||dp4[j]!=-inf);
		if (!op)
		{
			printf("%d\n",n-(i-1));
			return 0;
		}
	}
	return 0;
}
